/**	
*	
	Doyle Spiral
*/

import ij.ImagePlus;
import ij.plugin.PlugIn;
import ij.process.ColorProcessor;
import ij.process.ImageProcessor;

import java.awt.Color;
import java.awt.Polygon;


import pluginUtils.DoyleCircle;


public class rayon_ extends ImagePlus implements PlugIn {
	private ImageProcessor primeIP; 
	private int X=2000,Y=2000; 
	private void drawCircle(DoyleCircle c){
		int intX=(int)(c.getXcenter()*X);
		int intY=(int)(c.getYcenter()*Y);
		int intR=(int)(c.getRadius()*X); // X ??
		primeIP.drawOval(intX-intR,intY-intR,intR*2,intR*2);
		primeIP.fillOval(intX-5,intY-5,10,10);
		
	}
	

	public void run(String arg) {
		primeIP = new ColorProcessor(X,Y);
		primeIP.setLineWidth(5);
		
		DoyleCircle init=new DoyleCircle(0.5,0.5,0.0,0.5,0,0); 
		
		Polygon background=new Polygon(new int[]{0,0,X,Y},new int[]{0,X,Y,0},4);
		primeIP.setColor(new Color(0.9f,0.9f,0.82f));
		
		primeIP.fillPolygon(background);
		primeIP.setColor(new Color(0.9f,0.0f,0.82f));
		drawCircle(init);
		
		double theta=0; 
		double increment=Math.PI/5; 
		for(int i=0;i<10;i++){
			primeIP.drawLine(1000,1000,1000+(int)(999*Math.cos(theta)),1000+(int)(999*Math.sin(theta)));
			theta=theta+increment;
		}
		theta=Math.PI/2; 
		primeIP.setColor(Color.BLUE); 
		primeIP.drawLine(1000,1000,1000+(int)(999*Math.cos(theta)),1000+(int)(999*Math.sin(theta)));
		primeIP.drawLine(1000,1000,1000+(int)(999*Math.cos(-theta)),1000+(int)(999*Math.sin(-theta)));
		setProcessor("Verifying", primeIP);
		show();
	}

	

}
